<%@page import="controller.Utils"%>
<%@page import="java.text.NumberFormat"%>
<%@page import="java.util.Date"%>
<%@page import="models.Domain"%>
<%
String strs = (String) request.getAttribute("strs");
String name = (String) request.getAttribute("name");
Domain domain = (Domain) request.getAttribute("domain");
	
Date date = new Date();
Date dates = new Date();
if(domain.getDate() != null)
{
	dates = domain.getDate();
}
long seconds = (date.getTime() - dates.getTime())/1000;
long day = (int) (seconds / 86400);
long hour = (int) ((seconds - day*86400) / 3600);
long minute = (int) ((seconds - day*86400 - hour*3600) / 60);


NumberFormat nf = NumberFormat.getInstance();
String title = domain.getDomain();
String description = domain.getDomain();
String keyword = domain.getDomain();
if(domain.getTitle()!=null)
{
	title +=" - "+domain.getTitle()+" - "+Utils.returnDomain(domain.getDomain()); 	
}
if(domain.getDescription()!=null)
{
	description +=" - "+domain.getDescription().getValue(); 	
}
if(description.length()<70&&domain.getDes()!=null)
{
	description+=domain.getDes().getValue();
}
if(description.length()<40)
	description+=",here you can find full information about "+domain.getDomain()+" as whois,ip,backlink";
if(description.length()>250)
	description=description.substring(0,240);

String nameDomain = domain.getDomain();
String dedate = (dates.getYear()+1900)+"-"+(dates.getMonth()+1)+"-"+dates.getDate();

%>
<%
	request.setCharacterEncoding("utf-8");
%>

<jsp:include page="layout/header.jsp">
	<jsp:param name="title" value="<%=title %>" />
	<jsp:param name="description" value="<%=description %>" />
	<jsp:param name="keywords" value="<%=keyword %>" />
	<jsp:param name="name" value="<%=nameDomain %>" />
	<jsp:param name="link" value="detail" />
	<jsp:param name="date" value="<%=dedate %>" />
</jsp:include>
<div class="frame-search">
	<div class='clear_div search-detail search'>
		<form action="/search" method="get">
			<input class="input" type="text" name="name"
				onclick="javascript:if(this.value=='Search the site here...')this.value=''"
				value="Search the site here...">
			<button type="submit">Search</button>
			<div class="clear clear_div"></div>
		</form>
		
		<div class="addthis clear_div addthis-detail">
		<!-- AddThis Button BEGIN -->				
			<div class="addthis_toolbox addthis_default_style ">
			<a class="addthis_button_facebook_like" fb:like:layout="button_count"></a>
			<a class="addthis_button_tweet" tw:via="moodify_site"></a>
		
			<a class="addthis_button_google_plusone" g:plusone:size="medium"></a>
			<a class="addthis_counter addthis_pill_style"></a>
			</div>
		                <script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=ra-4d6f3cdb1d190d60"></script>
		                <!-- AddThis Button END -->
		</div>	
		<div class="clear clear_div"></div>
	</div>
</div>	
<div id="content">
	<div>
		<jsp:include page="/adv/728x15.jsp"></jsp:include>
		<h1><%=domain.getDomain() %></h1>
		<p>
			<%=domain.getTitle() %><br/>
			<%=domain.getDescription()!=null?domain.getDescription().getValue():"" %>
		</p>
		<jsp:include page="/adv/468x60.jsp"></jsp:include>
		<p class="back">Has Alexa Rank of # <strong><%=nf.format(domain.getAlexa()) %></strong> and Google Page Rank of # <strong><%=domain.getGoogle() %></strong>. </p>
		<p>Updated
			<%
				if(day > 0)
									{
										out.print("<strong>"+day+" days</strong>, ");
									}
									if(hour > 0)
									{
										out.print("<strong>"+hour+" hours</strong>, ");
									}
									out.print(minute+" minutes");
			%>
				Ago
				
			<%
			if(day>=2 || domain.getDate() == null)
			{
			%>
						<strong class="size"> ( <a href="javascript:void(0)" rel="nofollow" id="update">Update</a> ) </strong>
			<%
			}
			%>
		</p>
		<div class="adv336">
			<jsp:include page="/adv/336x280.jsp"></jsp:include>
		</div>
		<div class="alexa">
			<object width="550" height="275" style="visibility: visible;" id="ammap_c8de625c0bde43c1c5036fb36091bc6b" data="http://www.alexa.com/amMap/ammap.swf" name="ammap_c8de625c0bde43c1c5036fb36091bc6b" bgcolor="#E9F0FF" path="http://www.alexa.com/amMap/ammap/" data_file="http://www.alexa.com/amMap/index.php?settings=<%=domain.getDomain() %>;country_traffic" settings_file="http://www.alexa.com/amMap/ammap_settings.xml" wmode="transparent" type="application/x-shockwave-flash" class="left">
				<param value="transparent" name="wmode">
				<param value="http://www.alexa.com/amMap/ammap_settings.xml" name="settings_file">
				<param value="http://www.alexa.com/amMap/index.php?settings=<%=domain.getDomain() %>;country_traffic" name="data_file">
				<param value="http://www.alexa.com/amMap/ammap/" name="path">
				<param value="wmode=transparent&amp;settings_file=http://www.alexa.com/amMap/ammap_settings.xml&amp;data_file=http://www.alexa.com/amMap/index.php?settings=<%=domain.getDomain() %>;country_traffic&amp;path=http://www.alexa.com/amMap/ammap/" name="flashvars">
			</object>
		</div>
		<div class="clear"></div>
		
		<h4>Alexa stats ( Rank: #<%=nf.format(domain.getAlexa()) %> )</h4>
		<div class="start_alexa clear_div">	
			<ul class="b-menu-01">
				<li class="current" id="gr_traffic"><a
					onclick="viewGraphTab('traffic'); return false;" href="#"><b>Traffic</b> </a>
				</li>
				<li id="gr_reach" class=""><a
					onclick="viewGraphTab('reach'); return false;" href="#"><b>Reach</b>
				</a>
				</li>
				<li id="gr_page" class=""><a
					onclick="viewGraphTab('page'); return false;" href="#"><b>Pageviews</b>
				</a>
				</li>
				<li id="gr_page_user" class=""><a
					onclick="viewGraphTab('page_user'); return false;" href="#"><b>Pageviews/User</b>
				</a>
				</li>
				<li id="gr_bounce" class=""><a
					onclick="viewGraphTab('bounce'); return false;" href="#"><b>Bounce
							%</b> </a>
				</li>
				<li id="gr_time" class=""><a
					onclick="viewGraphTab('time'); return false;" href="#"><b>Time
							on Site</b> </a>
				</li>
				<li id="gr_search" class=""><a
					onclick="viewGraphTab('search'); return false;" href="#"><b>Search
							%</b> </a>
				</li>
			</ul>
			<form class="f-alexa">
				<div class="f-alexa-left clear_div">
					<select id="selectPeriod" class="inp-select">
						<option value="7d">Trailing 7 days</option>
						<option value="1m">Trailing 1 month</option>
						<option selected="selected" value="3m">Trailing 3 months</option>
						<option value="6m">Trailing 6 months</option>
						<option value="2y">Max</option>
					</select>
					<h4>Compare this site to:</h4>
					<input type="text" class="inp-text compare-to"> <input
						type="text" class="inp-text compare-to"> <input type="text"
						class="inp-text compare-to"> <input type="text"
						class="inp-text compare-to"> <input type="button"
						onclick="compareTo(); return false;" value="Compare"
						class="inp-submit-01">
				</div>
				<div class="f-alexa-right clear_div">
					<img
						src="http://traffic.alexa.com/graph?&amp;w=400&amp;h=220&amp;o=f&amp;c=1&amp;y=t&amp;b=ffffff&amp;n=666666&amp;r=3m&amp;u=<%=domain.getDomain() %>"
						id="alexaGraphic" alt="traffic alexa for <%=domain.getDomain() %>"/>
				</div>
			</form>
		</div>
		<div class="adv300 clear_div">
			<jsp:include page="/adv/336x280.jsp"></jsp:include>
		</div>
		<div class="clear"></div>
		<h2>Magestic Backlinks for: <%=domain.getDomain() %></h2>
		<img alt="backlink for <%=domain.getDomain() %>" src="http://www.majesticseo.com/charts/backlinks-discovery?ctype=0&amp;w=950&amp;a=1&amp;h=250&amp;IndexDataSource=F&amp;bc=EAEEF0&amp;d=<%=domain.getDomain() %>" id="magestic_image">
		
		<h2>About site</h2>
		<div class="clear_div">
			<table>
				<tr>
					<td width="150">Subdomain</td>
					<td><%=domain.getDomain()%> <%=Utils.returnSubDomain(domain.getDomain()) %></td>
				</tr>
				<%
				if(domain.getAge()!=null&&!domain.getAge().equals(""))
				{
				%>
				<tr>
					<td width="150">Domain Age</td>
					<td><%=domain.getAge() %></td>
				</tr>
				<%
				}
				%>
				<%
				if(domain.getAdsense()!=null&&!domain.getAdsense().equals(""))
				{
				%>
				<tr>
					<td width="150">Google Adsense</td>
					<td><a href="/adsense/<%=domain.getAdsense() %>"><%=domain.getAdsense() %></a></td>
				</tr>
				<%
				}
				%>
				<%
				if(domain.getAnalytic()!=null&&!domain.getAnalytic().equals(""))
				{
				%>
				<tr>
					<td width="150">Google Analytic</td>
					<td><a href="/analytic/<%=domain.getAnalytic() %>"><%=domain.getAnalytic() %></a></td>
				</tr>
				<%
				}
				%>
				<%
				if(domain.getIp()!=null&&!domain.getIp().equals(""))
				{
				%>
				<tr>
					<td width="150">IP Address</td>
					<td><a href="/ip/<%=domain.getIp() %>" title="domain same ip"><%=domain.getIp() %></a></td>
				</tr>
				<%
				}
				%>
				<%
				if(domain.getServer()!=null&&!domain.getServer().equals(""))
				{
				%>
				<tr>
					<td width="150">Web server</td>
					<td><%=domain.getServer() %></td>
				</tr>
				<%
				}
				%>
				<%
				if(domain.getLanguage()!=null&&!domain.getLanguage().equals(""))
				{
				%>
				<tr>
					<td width="150">Language</td>
					<td><%=domain.getLanguage() %></td>
				</tr>
				<%
				}
				%>
				<%
				if(domain.getJs()!=null&&!domain.getJs().equals(""))
				{
				%>
				<tr>
					<td width="150">Javascript library</td>
					<td><%=domain.getJs() %></td>
				</tr>
				<%
				}
				%>
				<%
				if(domain.getKeywords()!=null)
				{
				%>
				<tr>
					<td width="150">Keyword</td>
					<td><%=domain.getKeywords().getValue()%></td>
				</tr>
				<%
				}
				%>
				<%
				if(domain.getPopularKeyword()!=null)
				{
				%>
				<tr>
					<td width="150">Popular Keyword</td>
					<td><%=domain.getPopularKeyword().getValue()%></td>
				</tr>
				<%
				}
				%>
				<%
				if(domain.getOutLink().size()>0)
				{
				%>
				<tr>
					<td width="150">Outbound link</td>
					<td>
						<%
						for(int i=0;i<domain.getOutLink().size();i++)
						{
							out.print("<a href='/site/"+Utils.fomatDomain(domain.getOutLink().get(i))+"'>"+Utils.fomatDomain(domain.getOutLink().get(i))+"</a>, ");
							if(i==10)
								break;
						}
						%>
						<br/>View all Out link <a href="/out-link/<%=domain.getDomain()%>"><%=domain.getDomain()%></a>
					</td>
				</tr>
				<%
				}
				%>
				<tr>
					<td>Inbound links</td>
					<td>View all In link <a href="/in-link/<%=domain.getDomain()%>"><%=domain.getDomain()%></a></td>
				</tr>
				<%
				if(!domain.getOtherDomain().equals(""))
				{
				%>
				<tr>
					<td width="150">Other domain</td>
					<td>
						<%
							String[] oth = domain.getOtherDomain().split(",");
							for(int i=0;i<oth.length;i++)
							{
								out.print("<a href=\"/site/"+oth[i]+"\">"+oth[i]+"</a>, ");
							}
						%>
					</td>
				</tr>
				<%
				}
				%>
			</table>
			<%
			if(domain.getHeader()!=null)
			{
			%>
				<h2>HTTP Headers</h2>
				<%=domain.getHeader().getValue() %>
			<%
			}
			%>
			<%
			if(domain.getDns()!=null)
			{
			%>
				<h2>DNS Records</h2>
				<%=domain.getDns().getValue() %>
 			<%
			}
			%>
			<%
			if(domain.getTrace()!=null)
			{
			%>
	 			<h2>Trace</h2>
	 			<%=domain.getTrace().getValue() %>
 			<%
			}
			%>
			
		</div>
		<%
		if(domain.getWhois()!=null)
		{
		%>
			<h2>Whois data</h2>
			<%=Utils.cleanWhois(domain.getWhois().getValue()) %>
		<%
		}
		%>
	</div>
</div>
<div id="opacity"></div>
<img id="image_loadder" src="/images/ajax.gif">
<script>
graphDomain='<%=domain.getDomain()%>';

</script> 
<script type="text/javascript" src="/js/jquery.js"></script>      
<script type="text/javascript" src="/js/detail.js"></script>
<jsp:include page="layout/footer.jsp"></jsp:include>
